package com.sdgs.paas.sdk.core;

import java.io.Serializable;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

import org.springframework.util.StringUtils;

/**
 * SDK基础对象，提供了一个{@link IPaasParam}的标准实现
 *
 * @author wjj
 * 
 */
public abstract class PaasBaseObject implements Serializable, IPaasParam {

	/**
	 * 
	 */
	private static final long serialVersionUID = -7630281316712769831L;
	

	@Override
	public String paramInfo() {

		List<String> params = Arrays.asList(this.getClass().getDeclaredFields()).stream().map(e -> {
			e.setAccessible(true);
			StringBuilder sb = new StringBuilder();
			try {
				return sb.append(e.getName()).append("=").append(e.get(this)).toString();
			} catch (Exception e1) {
				return sb.append(e.getName()).append("=").append("unknown").toString();
			}
		}).collect(Collectors.toList());
		StringBuilder sb = new StringBuilder();
		sb.append("Class=").append(this.getClass().getName()).append(",").append(StringUtils.collectionToCommaDelimitedString(params));
		
		return this.buildParamInfo(StringUtils.commaDelimitedListToStringArray(sb.toString()));
	}

}
